package com.jidong.test_springboot.entity;

import java.util.Date;

import org.springframework.format.annotation.DateTimeFormat;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;

@Data
@AllArgsConstructor
@NoArgsConstructor
@ToString
@TableName(value="t_user")
public class User {
	@TableId(type=IdType.AUTO) //插入数据时立即获得该数据的id
	private int id;
	@TableField(value="uname")
	private String name;
	@TableField(value="gender")
	private String gender;
	@TableField(value="age")
	private int age;
	@TableField(value="pwd")
	private String pwd;
	
	@TableField(value="dept_id")
	private int deptId;
	
	@TableField(exist=false) //该字段不和数据库匹配 这个是在用户列表的高级表单方式里用到的，前端user2包不用这个
	private boolean editable;
	
	@TableField(value="birthday")
	// 这个是把前端的字符串类型转为了Date类型
	@DateTimeFormat(pattern = "yyyy-MM-dd") //这个注解的作用是把前端传来的字符串类型的birthday自动按格式转为日期类型
	@JsonFormat(pattern="yyyy-MM-dd",timezone="GMT+8")
	private Date birthday;
	@TableField(value="avatar")
	private String avatar;
	
	public User(String name, String gender, int age, String pwd) {
		this.name = name;
		this.gender = gender;
		this.age = age;
		this.pwd = pwd;
	}
	
	public User(int id,String name, String gender, int age, String pwd) {
		this.id=id;
		this.name = name;
		this.gender = gender;
		this.age = age;
		this.pwd = pwd;
	}
	
}
